{template 'common/header'}
<div class="account-list-add-step" id="js-miniapp-create" ng-controller="CreateMiniappCtrl" ng-cloak>
	<ol class="breadcrumb we7-breadcrumb">
		<a href="{php echo url('account/manage', array('account_type' => ACCOUNT_TYPE_ALIAPP_NORMAL))}"><i class="wi wi-back-circle"></i></a>
		<li><a href="{php echo url('account/manage', array('account_type' => ACCOUNT_TYPE_ALIAPP_NORMAL))}">支付宝小程序列表</a></li>
		<li>新建支付宝小程序</li>
	</ol>
	<div class="we7-step">
		<ul>
			<li ng-class="createStep == 1 ? 'active': ''">1 设置支付宝小程序信息</li>
			<li ng-class="createStep == 2 ? 'active': ''">2 生成版本</li>
		</ul>
	</div>
	<form method="post" ng-submit="package()">
		<input name="token" type="hidden" value="{$_W['token']}">
		<div class="panel panel-app">
			<div class="panel-body">
				<div class="wxapp-content tab-content" style="width: 100%;">
					<div id="select" ng-show="createStep == 1">
						<div class="form-defalut we7-form">
							{if empty($uniacid)}
							<div class="form-group">
								<label for="" class="control-label col-sm-2">支付宝小程序名称</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="name" ng-model="miniapp.name" class="form-control wxapp-name" placeholder="小程序名称">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="control-label col-sm-2">支付宝小程序描述</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="description" ng-model="miniapp.description" class="form-control wxapp-name" placeholder="版本描述">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="control-label col-sm-2">AppId</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="key" value="" ng-model="miniapp.appid" class="form-control wxapp-name" placeholder="AppId">
								</div>
							</div>
							{else}
							<div class="form-group">
								<label for="" class="control-label col-sm-2">版本描述</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="description" ng-model="miniapp.description" class="form-control wxapp-name" placeholder="版本描述">
								</div>
							</div>
							{/if}
							<div class="form-group">
								<label for="" class="control-label col-sm-2">版本号</label>
								<div class="form-controls col-sm-10">
									<input type="text" name="version" ng-model="miniapp.version" class="form-control wxapp-name" placeholder="版本号，只能是数字、点，数字最多两位，例如 1.01 / 1.0.1">
								</div>
							</div>
							<div class="form-group" ng-show="newversion">
								<label for="" class="control-label col-sm-2">头像</label>
								<div class="form-controls col-sm-8">
									<div class="input-more we7-input-img" ng-class="{'active': miniapp.headimg}">
										<img ng-src="{{miniapp.headimg}}" width="150px" ng-if="miniapp.headimg" ng-style="{'height': 'auto'}">
										<a href="javascript:;" class="input-addon" ng-click="uploadMultiImage('headimg')" ng-hide="miniapp.headimg"><span>+</span></a>
										<input type="text" name="headimg" ng-model="miniapp.headimg" ng-style="{'display' : 'none'}">
										<div class="cover-dark">
											<a href="javascript:;" class="cut" ng-click="uploadMultiImage('headimg')">更换</a>
											<a href="javascript:;" class="del" ng-click="delMultiImage('headimg')"><i class="fa fa-times text-danger"></i></a>
										</div>
									</div>
									<span class="help-block"></span>
								</div>
							</div>
							<div class="form-group" ng-show="newversion">
								<label for="" class="control-label col-sm-2">二维码</label>
								<div class="form-controls col-sm-8">
									<div class="input-more we7-input-img" ng-class="{'active': miniapp.qrcode}">
										<img ng-src="{{miniapp.qrcode}}" width="150px" ng-if="miniapp.qrcode" ng-style="{'height': 'auto'}">
										<a href="javascript:;" class="input-addon" ng-click="uploadMultiImage('qrcode')" ng-hide="miniapp.qrcode"><span>+</span></a>
										<input type="text" name="qrcode" ng-model="miniapp.qrcode" ng-style="{'display' : 'none'}">
										<div class="cover-dark">
											<a href="javascript:;" class="cut" ng-click="uploadMultiImage('qrcode')">更换</a>
											<a href="javascript:;" class="del" ng-click="delMultiImage('qrcode')"><i class="fa fa-times text-danger"></i></a>
										</div>
									</div>
									<span class="help-block"></span>
								</div>
							</div>
							<div class="form-group">
								<input type="hidden" name="modules" value="">
								<label class="control-label col-sm-2">添加应用</label>
								<div class="form-controls col-sm-10">
									<ul class="app-list" id="resource_module">
										<div class="app-info">
											<img ng-src="{{miniapp.choose_module.icon}}" />
											<p>{{miniapp.choose_module.title}}</p>
										</div>
										<li class="select select-more"></li>
									</ul>
								</div>
							</div>
						</div>
					</div>
					<div id="finish" ng-show="createStep == 2">
						<div class="form we7-form wxapp-finish">
							<div class="form-group" ng-show="newversion">
								<label for="" class="control-label col-sm-2">小程序名称</label>
								<div class="form-controls col-sm-10">
									<p class="form-control-static" ng-bind="miniapp.name"></p>
								</div>
							</div>
							<div class="form-group">
								<label for="" class="control-label col-sm-2">描述</label>
								<div class="form-controls col-sm-10">
									<p class="form-control-static" ng-bind="miniapp.description"></p>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-sm-2">版本号</label>
								<div class="form-controls col-sm-10">
									<p class="form-control-static">{{miniapp.version}}</p>
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-sm-2">打包应用</label>
								<div class="form-controls col-sm-10">
									<ul class="app-list">
										<li class="select">
											<div class="app-info">
												<img ng-src="{{miniapp.choose_module.icon}}" />
												<p>{{miniapp.choose_module.title}}</p>
											</div>
										</li>
									</ul>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<nav class="navbar navbar-wxapp-bottom navbar-fixed-bottom" role="navigation">
			<div class="container">
				<div class="pager">
					<a type="button" class="btn btn-primary" ng-show="createStep != 1" ng-click="prevStep()">上一步</a>
					<a type="button" class="btn btn-primary" ng-show="createStep != 2" ng-click="nextStep()">下一步</a>
					<button type="submit" name="submit" value="yes" class="btn btn-danger" ng-show="createStep == 2">生成版本</button>
				</div>
			</div>
		</nav>
	</form>
</div>
<script>
require(['fileUploader','underscore'], function(uploader){
	var miniapp = {'name' : '{$wxapp_info['name']}'};
	angular.module('wxApp').value('config', {
		'type' : "{$type}",
		'miniapp' : miniapp,
		'uniacid' : "{$uniacid}",
		'version_id' : "{$version_id}",
		'postUrl' : "{php echo url('miniapp/post', array('version_id' => $version_id))}",
		'token' : "{$_W['token']}",
	});

	angular.bootstrap($('#js-miniapp-create'), ['wxApp']);
});
</script>
</html>